GBML manual / Instances

xstart

Where x was when this instance was created - never changes afterward.

Syntax

xstart: real (read-only in practice)

Description

Where x was the instant this instance was created - set once, from instance_create's own position, and never touched again afterward no matter how far the instance travels.

Like x itself, it is a place in the room counted from the room's top-left corner, so it can be compared with x directly.

Useful as a fixed anchor: a patrol that should always return home, a projectile that should despawn once it has flown far enough from where it was fired.

Example

if (x > xstart + 200 || x < xstart - 200) {
    instance_destroy(self);
}

Destroys the bolt once x has moved more than 200 pixels away from xstart, its own fixed starting point - a simple, self-contained range check (there is no built-in distance function yet - see dist_to - so this checks one axis at a time rather than true straight-line distance).